home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dr.bub / 96000.lha / 96000 / appb / b129.asm < prev    next >
Assembly Source File  |  1992-04-28  |  2KB  |  38 lines

  1. ; This program was originally published in the Motorola DSP96002 Users Manual
  2. ; and is provided under a DISCLAIMER OF WARRANTY available from Motorola DSP
  3. ; Operation, 6501 William Cannon Drive West, Austin, Texas 78735-8598.  For
  4. ; more information, refer to the DSP96002 Users Manual, Appendix B, DSP
  5. ; Benchmarks.
  6. ;
  7.  
  8. ; B.1.29    Newton-Raphson Approximation for 1.0/SQRT(x)  
  9. ;The Newton-Raphson iteration can be used to approximate the function:  
  10. ;        1.0 
  11. ;           y= ------- 
  12. ;              sqrt(x) 
  13. ;
  14. ;by minimizing the function:  
  15. ;                             1.0 
  16. ;           F(y) = x  -   ------- 
  17. ;                           y*y 
  18. ;
  19. ;Given an initial approximate value y=1/sqrt(x), the Newton-Raphson  iteration for refining the esti-
  20. ;mate is:  
  21. ;    y(n+1)=y(n)*(3.0-x*y*y)/2.0 
  22. ;
  23. ;              Newton-Raphson Approximation                  Program    ICycles 
  24. ;                     of 1.0/SQRT(x)                         Words 
  25.     seedr   d5,d4                    ;y approx 1/sqrt(x)    1       1 
  26.     fmpy.s  d4,d4,d2       #.5,d7.s  ;y*y, get .5           2       2 
  27.     fmpy.s  d5,d2,d2       #3.0,d3.s ;x*y*y, get 3.0        2       2 
  28.     fmpy    d4,d7,d2  fsub.s d2,d3  d3.s,d6.s ;y/2, 3-x*y*y 1       1 
  29.     fmpy.s  d2,d3,d4       d6.s,d3.s ;y/2*(3-x*y*y)         1       1 
  30.     fmpy.s  d4,d4,d2                 ;y*y                   1       1 
  31.     fmpy.s  d5,d2,d2                 ;x*y*y                 1       1 
  32.     fmpy    d4,d7,d2  fsub.s d2,d3  d3.s,d6.s ;y/2, 3-x*y*y 1       1 
  33.     fmpy.s  d2,d3,d4                 ;y/2*(3-x*y*y)         1       1 
  34.  ;                                                          ---     --- 
  35.  ;                                                  Totals:    11    11 
  36.  
  37.